import request from "@/utils/request";

// 学生登录
export const login = (student) => request.post('/student/stuLogin/login', student)

// 修改密码
export const updatePassword = (payload) => request.post('/student/stuLogin/updatePassword', payload)

// 学生活动分页列表
export const queryActivityList = (query) => request.post('/student/activity/list', query)

// 学生已报名活动列表
export const queryEnrolledActivityList = (query) => request.post('/student/activity/enrolled', query)

// 根据ID查询活动详情
export const getActivityDetail = (id) => request.get(`/student/activity/find?id=${id}`)

// 获取当前登录学生信息
export const getStudentInfo = () => request.get('/student/student/findInfo')

// 更新学生个人信息
export const updateStudentInfo = (student) => request.post('/student/student/updateStudentInfo', student)

// 上传图片
export const uploadImage = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/upload/image', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 活动报名
export const applyActivity = (activityId) => {
  return request.post('/student/activity/applyActivity', null, {
    params: { activityId }
  })
}

// 取消报名
export const cancelApplication = (activityId) => {
  return request.delete('/student/activity/cancel', {
    params: { activityId }
  })
}

// 获取报名状态
export const getApplicationStatus = (activityId) => {
  return request.get('/student/activity/applicationStatus', {
    params: { activityId }
  })
}

// ========== 活动反馈相关接口 ==========

// 提交活动反馈
export const submitFeedback = (feedback) => {
  return request.post('/student/feedback/submit', feedback)
}

// 查询某活动的反馈
export const getFeedbackByActivity = (activityId) => {
  return request.get('/student/feedback/findByActivity', {
    params: { activityId }
  })
}
